package com.css.dzj.dzjap.modules.lawenforcesuper.mapper;

import com.css.dzj.dzjap.modules.lawenforcesuper.entity.GeneralWorkInfoEntity;
import com.css.dzj.dzjap.modules.lawenforcesuper.view.GeneralQueryVo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository
public interface GenralMapper extends JpaRepository<GeneralWorkInfoEntity, String>, JpaSpecificationExecutor<GeneralWorkInfoEntity>,
        QuerydslPredicateExecutor<GeneralWorkInfoEntity> {

    @Query(value = "select g.taskId,sum(g.extratNum) from GeneralWorkInfoEntity g where g.createPersonLocation = :location and (:title is null or g.taskTitle like CONCAT('%',:title,'%')) group by g.taskId order by g.createTime desc ",nativeQuery = false)
    Page<GeneralWorkInfoEntity> getTaskIdByLocation(@Param("title") String title,@Param("location") String location,Pageable pageable);
    @Query(value = "select g.taskId,sum(g.extratNum) from GeneralWorkInfoEntity g  where  (:title is null or g.taskTitle like CONCAT('%',:title,'%')) group by g.taskId order by g.createTime desc",nativeQuery = false)
    Page<GeneralWorkInfoEntity> getTaskId(@Param("title") String title,Pageable pageable);

}
